﻿using UnityEngine;
using System.Collections;

public class NeuronThreshold : Neuron {

	public float left = 0;
	public float right = 1;
	public float threshold = 0.5f;
		
		public float probeInputFloat = 0.5f;
		public float probeOutputFloat = 0.5f;
		
		void Start () {
			axon = soma = 32767;
		}
		
		public ushort activationFunction(ushort u) {
			float f = Mathf.Clamp01 (u / 65534.0f);
	
			f = (f < threshold) ? f = left : f = right;
				
			f = Mathf.Clamp01 (f);
			return (ushort)(f * 65534.0f);
		}
		
		void FixedUpdate () {
			if (synapse > 65534)
				synapse = 65534;
			if (synapse < 0)
				synapse = 0;
			soma = (ushort)synapse;
			synapse = 32767;
			
			axon = activationFunction(soma);
		}
		
		
		public override float activationFunctionf(float f) {
			return activationFunction ((ushort)(f * 65534.0f)) / 65534.0f;
		}
		
		
		
		
		
	}
